1 <?php
2 session_start();
// Use session variable on this page. This function must put on the top of page.
3 if
(!isset($_SESSION['username']) || $_SESSION['usertype'] !='admin'){ // if session variable "username" does not exist.
4 header(
"location:index.php?msg=Please%20login%20to%20access%20admin%20area%20!"); // Re-direct to index.php
5 }

6 else

7 {
8     include_once
"db.php";
9     error_reporting (E_ALL ^ E_NOTICE);
10
11 ?><!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
12 "http:
//www.w3.org/TR/html4/loose.dtd">
13 <html>
14 <head>
15 <title>Welcome to Stock Management System !</title>
16 <meta http-equiv=
"Content-Type" content="text/html; charset=iso-8859-1">
17 <META Http-Equiv=
"Cache-Control" Content="no-cache">
18 <META Http-Equiv=
"Pragma" Content="no-cache">
19 <META Http-Equiv=
"Expires" Content="0">
20 <link rel=
"stylesheet" href="css/validationEngine.jquery.css" type="text/css" media="screen" title="no title" charset="utf-8" />
21         <link rel=
"stylesheet" href="css/template.css" type="text/css" media="screen" title="no title" charset="utf-8" />
22         <script src=
"js/jquery.min.js" type="text/javascript"></script>
23         <script type=
"text/javascript" src="jquery.date_input.js"></script>
24 <link rel=
"stylesheet" href="date_input.css" type="text/css">
25 <script type=
"text/javascript">$(function() {
26   $(
"#datefield").date_input();
27    $(
"#due").date_input();
28 });</script>
29
30 <script type=
'text/javascript' src='lib/jquery.bgiframe.min.js'></script>
31 <script type=
'text/javascript' src='lib/jquery.ajaxQueue.js'></script>
32 <script type=
'text/javascript' src='lib/thickbox-compressed.js'></script>
33 <script type=
'text/javascript' src='jquery.autocomplete.js'></script>
34
35 <script type=
'text/javascript' src='localdata.js'></script>
36
37 <link rel=
"stylesheet" type="text/css" href="jquery.autocomplete.css" />
38 <link rel=
"stylesheet" type="text/css" href="lib/thickbox.css" />
39     
40 <script type=
"text/javascript">
41 $().ready(function() {
42
43     function log(
event, data, formatted) {
44         $(
"<li>").html( !data ? "No match!" : "Selected: " + formatted).appendTo("#result");
45     }
46     
47     function formatItem(row) {
48         
return row[0] + " (<strong>id: " + row[1] + "</strong>)";
49     }
50     function formatResult(row) {
51         
return row[0].replace(/(<.+?>)/gi, '');
52     }
53     
54     
55
56
57     
58     
59     $(
"#customer").autocomplete("customer.php", {
60         width:
160,
61         autoFill:
true,
62         selectFirst:
false
63     });
64     
65
66     
67 });
68
69
70 </script>
71
72         <script type=
"text/javascript" src="lib/jquery-ui-1.7.2.custom.min.js"></script>
73         <script type=
"text/javascript" src="jquery-dynamic-form.js"></script>
74         <script type=
"text/javascript">
75             $(document).ready(function(){
76                 $(
"#duplicate").dynamicForm("#plus", "#minus", {limit:50, createColor: 'yellow',removeColor: 'red'});
77                 
78             });
79         </script>
80         <script src=
"js/jquery.validationEngine-en.js" type="text/javascript"></script>
81         <script src=
"js/jquery.validationEngine.js" type="text/javascript"></script>
82          <script src=
"js/jquery.hotkeys-0.7.9.js"></script>
83         <!-- AJAX SUCCESS TEST FONCTION
84             <script>function callSuccessFunction(){alert(
"success executed")}
85                     function callFailFunction(){alert(
"fail executed")}
86             </script>
87         -->
88         
89         <script>
90         
91         function callAutoComplete(idname)
92     {
93     
94     $(
"#"+idname).autocomplete("stock.php", {
95         width:
160,
96         autoFill:
true,
97         mustMatch:
true,
98         selectFirst:
false
99     });
100     
101     
102     
103     }
104     
105     
106     function checkDublicateName()
107     {
var k=0;
108                 
for (i=0;i<=400;i=i+5)
109                     {
110                     
if($("#0"+i).length>0)
111                     { $k=
0;
112                              
for (j=0;j<=400;j=j+5)
113                             {
114                             
if($("#0"+j).length>0 && $("#0"+i).val()==$("#0"+j).val())
115                             {
116                              $k++;
117                              
118                             }
119                             }
120                         
if($k>1)
121                     {
122                     alert(
"Dublicate stock Entry. please remove new and add stock in existing one !");
123                     
124                     }
125                      
126                     }
127                     }
128                     
129                     
130                     
131                     
132                     
133     }
134
135     function callAutoAsignValue(idname)
136     {
137             
138              
var name1 = parseInt(idname,10);
139              
140             
var quantity1 = name1+1;
141             
142              
var rate1 = quantity1+1;
143              
var avail1 = rate1+1;
144              
var total1 = avail1+1;
145             
146              
if(parseInt(idname)>0)
147              {
148              quantity1=
"00"+quantity1;
149              rate1=
"000"+rate1;
150              avail1=
"0000"+avail1;
151              total1=
"00000"+total1;
152              
153              }
154              
else
155              {
156               quantity1=
"00";
157               rate1=
"000";
158               avail1=
"0000";
159               total1=
"00000";
160               
161              }
162              
163                  $.post(
'check_sales_details.php', {stock_name: $("#"+idname).val() },
164                 function(data){
165                                 
166                                 $(
"#"+rate1).val(data.rate);
167                                 $(
"#"+avail1).val(data.availstock);
168                                 $(
"#"+quantity1).focus();
169                             },
'json');
170                             
171                         checkDublicateName();
172                             
173     }
174     
175     
176     function callQKeyUp(Qidname)
177     {
178     
179             
180              
181              
var quantity = parseInt(Qidname,10);
182              
var rate = quantity+1;
183              
var avail = rate+1;
184              
var total = avail+1;
185              
var rowcount = parseInt((total+1)/5);
186              
if(rowcount==0)
187              rowcount=
1;
188             
189              
if(parseInt(Qidname)>0)
190              {
191              quantity=
"00"+quantity;
192              rate=
"000"+rate;
193              avail=
"0000"+avail;
194              total=
"00000"+total
195              }
196              
else
197              {
198               quantity=
"00";
199               rate=
"000";
200               avail=
"0000";
201               total=
"00000";
202               
203               
204              }
205             
var result= parseFloat($("#"+quantity).val()) * parseFloat( $("#"+rate).val() );
206             result=result.toFixed(
2);
207             $(
"#"+total).val(result);
208             
if(parseFloat($("#"+quantity).val()) > parseFloat($("#"+avail).val()))
209             $(
"#"+quantity).val(parseFloat($("#"+avail).val()));
210             
211             updateSubtotal();
212             
213     }
214     function balanceCalc()
215     {
if(parseFloat($("#payment").val()) > parseFloat($("#subtotal").val()))
216             $(
"#payment").val(parseFloat($("#subtotal").val()));
217             
218             
var result= parseFloat($("#subtotal").val()) - parseFloat( $("#payment").val() );
219             result=result.toFixed(
2);
220             $(
"#balance").val(result);
221             
222     }
223     function updateSubtotal()
224     {
225                     
var temp=0;
226                     
for (i=4;i<=400;i=i+5)
227                     {
228                     
if($("#00000"+i).length>0)
229                     {
230                      temp=parseFloat(temp)+parseFloat($(
"#00000"+i).val());
231                      
232                     }
233                     }
234                 
235             
236             
var subtotal=parseFloat(temp);
237             
238             
if($("#00000").length>0)
239             {
240             
var firstrowvalue=$("#00000").val();
241             
242             subtotal=parseFloat(subtotal)+parseFloat(firstrowvalue);
243             }
244             subtotal=subtotal.toFixed(
2);
245             $(
"#subtotal").val(subtotal);
246             
247             
248     }
249     
250     function callRKeyUp(Ridname)
251     {
252             
var rate = parseInt(Ridname,10);
253              
var quantity = rate-1;
254              
var avail = rate+1;
255              
var total = avail+1;
256              
257              
if(parseInt(Ridname)>0)
258              {
259              quantity=
"00"+quantity;
260              rate=
"000"+rate;
261              avail=
"0000"+avail;
262              total=
"00000"+total
263              
264              }
265              
else
266              {
267               quantity=
"00";
268               rate=
"000";
269               avail=
"0000";
270               total=
"00000";
271               
272              }
273             
274             
var result= parseFloat($("#"+quantity).val()) * parseFloat( $("#"+rate).val() );
275             result=result.toFixed(
2);
276             $(
"#"+total).val(result);
277             
if(parseFloat($("#"+quantity).val()) > parseFloat($("#"+avail).val()))
278             $(
"#"+quantity).val(parseFloat($("#"+avail).val()));
279             
280             updateSubtotal();
281     
282     }
283         
284         
285         $(document).ready(function() {
286             
// SUCCESS AJAX CALL, replace "success: false," by: success : function() { callSuccessFunction() },
287              $(
"#billnumber").focus();
288             
289             
/*$("#"+quantity).keyup(function (e) {
290             
291             $(
"#"+total).val( parseInt( $("#"+qunatity).val()) * parseInt( $("#"+rate).val() ));
292             
if(parseInt($("#"+quantity).val()) > parseInt($("#"+avail).val()))
293             $(
"#"+quantity).val(parseInt($("#"+avail).val()));
294             
295             });
296             
297             $(
"#"+rate).keyup(function (e) {
298             
299             $(
"#"+total).val( parseInt($("#"+quantity).val()) * parseInt($("#"+rate).val()) );
300             
if(parseInt($("#"+quantity).val()) > parseInt($("#"+avail).val()))
301             $(
"#"+quatity).val(parseInt($("#"+avail).val()));
302             
303             });
304                 */

305             
306              $(
"#customer").blur(function()
307             {
308             
309                  $.post(
'check_customer_details.php', {stock_name1: $(this).val() },
310                 function(data){
311                 
312                                 $(
"#address").val(data.address);
313                                 $(
"#contact1").val(data.contact1);
314                                 $(
"#contact2").val(data.contact2);
315                                 
if(data.address!=undefined)
316                                 $(
"#0").focus();
317                                 
318                             },
'json');
319                             
320                             
321                     
322
323             
324             });
325             $(
"#form1").validationEngine(),
326             
327             jQuery(document).bind(
'keydown', 'Ctrl+s',function() {
328           $(
'#form1').submit();
329           
return false;
330             });
331             
332             jQuery(document).bind(
'keydown', 'Ctrl+r',function() {
333           $(
'#form1').reset();
334           
return false;
335             });
336             jQuery(document).bind(
'keydown', 'Ctrl+a',function() {
337             window.location =
"add_stock_sales.php";
338           
return false;
339             });
340             jQuery(document).bind(
'keydown', 'Ctrl+0',function() {
341             window.location =
"admin.php";
342           
return false;
343             });
344             jQuery(document).bind(
'keydown', 'Ctrl+1',function() {
345             window.location =
"add_purchase.php";
346               
return false;
347             });
348             jQuery(document).bind(
'keydown', 'Ctrl+2',function() {
349             window.location =
"add_stock_sales.php";
350               
return false;
351             });
352             jQuery(document).bind(
'keydown', 'Ctrl+3',function() {
353             window.location =
"add_stock_details.php";
354               
return false;
355             });
356             jQuery(document).bind(
'keydown', 'Ctrl+4',function() {
357             window.location =
"add_category.php";
358               
return false;
359             });
360             jQuery(document).bind(
'keydown', 'Ctrl+5',function() {
361             window.location =
"add_supplier_details.php";
362               
return false;
363             });
364             jQuery(document).bind(
'keydown', 'Ctrl+6',function() {
365             window.location =
"add_customer_details.php";
366               
return false;
367             });
368             jQuery(document).bind(
'keydown', 'Ctrl+7',function() {
369             window.location =
"view_stock_entries.php";
370               
return false;
371             });
372             jQuery(document).bind(
'keydown', 'Ctrl+8',function() {
373             window.location =
"view_stock_sales.php";
374               
return false;
375             });
376             jQuery(document).bind(
'keydown', 'Ctrl+9',function() {
377             window.location =
"view_stock_details.php";
378               
return false;
379             });
380             
381             jQuery(document).bind(
'keyup', 'Ctrl+down',function() {
382             $(
'#plus').click();
383               
return false;
384             });
385             
//$.validationEngine.loadValidation("#date")
386             
//alert($("#formID").validationEngine({returnIsValid:true}))
387             
//$.validationEngine.buildPrompt("#date","This is an example","error") // Exterior prompt build example // input prompt close example
388             
//$.validationEngine.closePrompt(".formError",true) // CLOSE ALL OPEN PROMPTS
389         });
390     </script>
391 <style type=
"text/css">
392 <!--
393 body {
394     margin-left: 0px;
395     margin-top: 0px;
396     margin-right: 0px;
397     margin-bottom: 0px;
398     background-color: #FFFFFF;
399 }
400
401 *{
402 padding: 0px;
403 margin: 0px;
404 }
405 #vertmenu {
406 font-family: Verdana, Arial, Helvetica, sans-serif;
407 font-size:
100%;
408 width: 160px;
409 padding: 0px;
410 margin: 0px;
411 }
412
413 #vertmenu h1 {
414 display: block;
415 background-color:#FF9900;
416 font-size:
90%;
417 padding: 3px
0 5px 3px;
418 border: 1px solid #
000000;
419 color: #
333333;
420 margin: 0px;
421 width:159px;
422 }
423
424 #vertmenu ul {
425 list-style: none;
426 margin: 0px;
427 padding: 0px;
428 border: none;
429 }
430 #vertmenu ul li {
431 margin: 0px;
432 padding: 0px;
433 }
434 #vertmenu ul li a {
435 font-size:
80%;
436 display: block;
437 border-bottom: 1px dashed #C39C4E;
438 padding: 5px 0px 2px 4px;
439 text-decoration: none;
440 color: #
666666;
441 width:160px;
442 }
443
444 #vertmenu ul li a:hover, #vertmenu ul li a:focus {
445 color: #
000000;
446 background-color: #eeeeee;
447 }
448 .style1 {color: #
000000}
449 div.pagination {
450
451     padding: 3px;
452
453     margin: 3px;
454
455 }
456
457
458
459 div.pagination a {
460
461     padding: 2px 5px 2px 5px;
462
463     margin: 2px;
464
465     border: 1px solid #AAAADD;
466
467     
468
469     text-decoration: none;
/* no underline */
470
471     color: #
000099;
472
473 }
474
475 div.pagination a:hover, div.pagination a:active {
476
477     border: 1px solid #
000099;
478
479
480
481     color: #
000;
482
483 }
484
485 div.pagination span.current {
486
487     padding: 2px 5px 2px 5px;
488
489     margin: 2px;
490
491         border: 1px solid #
000099;
492
493         
494
495         font-weight: bold;
496
497         background-color: #
000099;
498
499         color: #FFF;
500
501     }
502
503     div.pagination span.disabled {
504
505         padding: 2px 5px 2px 5px;
506
507         margin: 2px;
508
509         border: 1px solid #EEE;
510
511     
512
513         color: #DDD;
514
515     }
516
517     
518 -->
519 </style>
520 </head>
521
522 <body>
523 <table width=
"100%" border="0" cellspacing="0" cellpadding="0">
524   <tr>
525     <td align=
"center" valign="top"><table width="960" border="0" cellspacing="0" cellpadding="0">
526       <tr>
527         <td><table width=
"960" border="0" cellpadding="0" cellspacing="0" bgcolor="#ECECEC">
528           <tr>
529             <td height=
"90" align="left" valign="top"><img src="images/topbanner.jpg" width="960" height="82"></td>
530           </tr>
531           <tr>
532             <td height=
"800" align="left" valign="top"><table width="960" border="0" cellpadding="0" cellspacing="0" bgcolor="#ECECEC">
533               <tr>
534                 <td width=
"130" align="left" valign="top">
535                 
536                 <br>
537
538                 <strong>Welcome <font color=
"#3399FF"><?php echo $_SESSION['username']; ?> !</font></strong><br> <br><table width="100%" border="0" cellspacing="0" cellpadding="0">
539   <tr>
540     <td align=
"center"><a href="admin.php"><img src="images/home.png" width="130" height="99" border="0"></a></td>
541     </tr>
542   <tr>
543     <td align=
"center">&nbsp;</td>
544     </tr>
545   <tr>
546     <td align=
"center"><a href="add_purchase.php"><img src="images/purchase.png" width="130" height="124" border="0"></a></td>
547     </tr>
548   <tr>
549     <td align=
"center">&nbsp;</td>
550     </tr>
551   <tr>
552     <td align=
"center"><a href="add_stock_sales.php"><img src="images/sales.png" width="146" height="111" border="0"></a></td>
553     </tr>
554   <tr>
555     <td align=
"center">&nbsp;</td>
556     </tr>
557   <tr>
558     <td align=
"center"><a href="report.php"><img src="images/reports.png" width="131" height="142" border="0"></a></td>
559     </tr>
560   <tr>
561     <td align=
"center">&nbsp;</td>
562     </tr>
563   <tr>
564     <td align=
"center">&nbsp;</td>
565     </tr>
566   <tr>
567     <td align=
"center">&nbsp;</td>
568     </tr>
569 </table>
570
571
572     
573                 
574                 
575                 </td> <td height=
"500" align="center" valign="top">
576 <table width=
"100%" border="0" cellspacing="0" cellpadding="0">
577   <tr>
578     <td><a href=
"add_stock_details.php"><img src="images/addstockdetails.png" width="67" height="62" border="0"></a></td>
579     <td><a href=
"add_supplier_details.php"><img src="images/supplier.png" width="67" height="54" border="0"></a></td>
580     <td><a href=
"add_customer_details.php"><img src="images/customer.png" width="67" height="54" border="0"></a></td>
581     <td><a href=
"add_category.php"><img src="images/categories.png" width="67" height="54" border="0"></a></td>
582     <td><a href=
"view_stock_sales.php"><img src="images/vsales.png" width="67" height="54" border="0"></a></td>
583     <td><a href=
"view_stock_entries.php"><img src="images/vpurchase.png" width="67" height="54" border="0"></a></td>
584     <td><a href=
"view_stock_details.php"><img src="images/stockdetails.png" width="67" height="54" border="0"></a></td>
585     <td><a href=
"view_stock_availability.php"><img src="images/savail.png" width="67" height="54" border="0"></a></td>
586     <td align=
"left" valign="top"><a href="view_customer_details.php"><img src="images/customers.png" width="94" height="22" border="0"></a><br>
587       <a href=
"view_supplier_details.php"><img src="images/suppliers.png" width="94" height="22" border="0"></a><br>
588       <a href=
"view_payments.php"><img src="images/payments.png" width="94" height="22" border="0"></a></td>
589     <td align=
"left" valign="top"><a href="view_stock_sales_payments.php"><img src="images/outstanding.png" width="94" height="22" border="0"></a><br> <a href="view_stock_entries_payments.php"><img src="images/pendings.png" width="94" height="22" border="0"></a><br>
590       <a href=
"logout.php"><img src="images/logout.png" width="94" height="22" border="0"></a></td>
591   </tr>
592 </table>
593 <?php
594                 
if(isset($_POST['billnumber']))
595
596             {
597             
598             $billnumber=mysql_real_escape_string($_POST[
'billnumber']);
599             $autoid=mysql_real_escape_string($_POST[
'id']);
600             $customer=mysql_real_escape_string($_POST[
'customer1']);
601             $address=mysql_real_escape_string($_POST[
'address1']);
602             $contact1=mysql_real_escape_string($_POST[
'contact1']);
603             $contact2=mysql_real_escape_string($_POST[
'contact2']);
604             $payment=mysql_real_escape_string($_POST[
'payment']);
605             $balance=mysql_real_escape_string($_POST[
'balance']);
606             
607             
608             
609                 $newvalue =$balance;
610                 $oldvalue = $db->queryUniqueValue(
"SELECT balance FROM customer_details WHERE customer_name='$customer'");
611                 $diff=$newvalue-$oldvalue;
612                 $temp_balance = (
int) $temp_balance + (int) $diff;
613                 $db->execute(
"UPDATE customer_details SET balance=$temp_balance WHERE customer_name='$customer'");
614             $selected_date=$_POST[
'due'];
615             $selected_date=strtotime( $selected_date );
616             $mysqldate = date(
'Y-m-d H:i:s', $selected_date );
617             $due=$mysqldate;
618             $mode=mysql_real_escape_string($_POST[
'mode']);
619             $description=mysql_real_escape_string($_POST[
'description']);
620             
621             $namet=$_POST[
'name'];
622             $quantityt=$_POST[
'quanitity'];
623             $ratet=$_POST[
'rate'];
624             $totalt=$_POST[
'total'];
625             $subtotal=mysql_real_escape_string($_POST[
'subtotal']);
626             
627             $username=$_SESSION[
'username'];
628             
629             $i=
0;
630             $j=
1;
631
632               
foreach($namet as $name1)
633                {
634                
635             $quantity=$_POST[
'quantity'][$i];
636             $rate=$_POST[
'rate'][$i];
637             $total=$_POST[
'total'][$i];
638             $selected_date=$_POST[
'date'];
639             $selected_date=strtotime( $selected_date );
640             $mysqldate = date(
'Y-m-d H:i:s', $selected_date );
641             $username = $_SESSION[
'username'];
642             
643             $count = $db->queryUniqueValue(
"SELECT count(*) FROM stock_avail WHERE name='$name1' and quantity >=$quantity");
644             
645             
if($count == 1)
646             {
647             
648                 
649              $old_quantity= $db->queryUniqueValue(
"SELECT quantity FROM stock_sales WHERE transactionid='$autoid' and count1=$i");
650             $db->query(
"update stock_sales set stock_name='$name1',selling_price=$rate,quantity=$quantity,amount=$total,date='$mysqldate',username='$username',customer_id='$customer',subtotal=$subtotal,payment=$payment,balance=$balance,due='$due',mode='$mode',description='$description',billnumber='$billnumber' where transactionid='$autoid' and count1=$j");
651             $quantity_diff=$quantity-$old_quantity;
652             $quantity=$quantity+$quantity_diff;
653             $amount = $db->queryUniqueValue(
"SELECT quantity FROM stock_avail WHERE name='$name1'");
654                 $amount1 = $amount - $quantity;
655             
656             $db->query(
"update stock_entries set stock_id='$autoid',stock_name='$name1',quantity=$quantity,opening_stock=$amount,closing_stock=$amount1,date='$mysqldate',username='$username',type='sales',salesid='$billnumber',total=$total,selling_price=$rate,billnumber='$billnumber' where salesid='$autoid' and count1=$j");
657             
//echo "<br><font color=green size=+1 >New Sales Added ! Transaction ID [ $autoid ]</font>" ;
658             
659             
660             
661             
//echo "<br><font color=green size=+1> Current Stock Availability is [ $amount1 ]</font>" ;
662             $j++;
663             
664             }
665             
else
666             {
667                 echo
"<br><font color=green size=+1 >There is no enough stock deliver for $name1! Please add stock !</font>" ;
668             }
669             
670             
671             
672             
673             
674             
675             
676             
677             $i++;
678             }
679             echo
"<div style='background-color:yellow;'><br><font color=green size=+1 >Sales Updated ! Transaction ID [ $autoid ]</font></div> ";
680             echo
"<script>window.open('add_sales_print.php?sid=$autoid','myNewWinsr','width=620,height=800,toolbar=0,menubar=no,status=no,resizable=yes,location=no,directories=no');</script>";
681             $count1 = $db->queryUniqueValue(
"SELECT count(*) FROM customer_details WHERE customer_name='$customer'");
682             
if($count1!=1)
683             {
684             
if($db->query("insert into customer_details values(NULL,'$customer','$address','$contact1','$contact2')"))
685             echo
"<br><font color=green size=+1 > [ $name ] Customer Details Updated !</font>" ;
686             }
687                 }
688                 ?>
689                 
690                 <br>
691 <br>
692
693                 <?php

694
695 if
(isset($_GET['id']))
696                 {
697                 
698                 $id=$_GET[
'id'];
699                 
700                 
701                 $line = $db->queryUniqueObject(
"SELECT * FROM stock_sales WHERE transactionid='$id'");
702                 
703                 ?>
704                 <form name=
"salesform" method="post" id="form1" action="" onSubmit="updateSubtotal()" >
705                   
706                   <p align=
"center"><strong>Edit Sales Entry </strong></p>
707                 
708                   <table width=
"800" border="0" cellspacing="0" cellpadding="0" id="dynamictable">
709                     <tr>
710                       <td width=
"61">&nbsp;</td>
711                       <td width=
"110">&nbsp;</td>
712                       <td width=
"15">&nbsp;</td>
713                       <td width=
"76">&nbsp;</td>
714                       <td width=
"171">&nbsp;</td>
715                       <td width=
"74">&nbsp;</td>
716                       <td width=
"111">&nbsp;</td>
717                       <td width=
"77">&nbsp;</td>
718                       <td width=
"105">&nbsp;</td>
719                     </tr>
720                     <tr>
721                       <td width=
"61">&nbsp;</td>
722                       <td width=
"110">&nbsp;</td>
723                       <td width=
"15">&nbsp;</td>
724                       <td width=
"76">&nbsp;</td>
725                       <td width=
"171">&nbsp;</td>
726                       <td width=
"74">&nbsp;</td>
727                       <td width=
"111">&nbsp;</td>
728                       <td width=
"77">&nbsp;</td>
729                       <td width=
"105">&nbsp;</td>
730                     </tr>
731                     <tr>
732                       <td width=
"61">&nbsp;</td>
733                       <td width=
"110">&nbsp;</td>
734                       <td>&nbsp;</td>
735                       <td><div align=
"left"><strong>ID</strong>
736                              
737                       </div></td>
738                       <td><input name=
"id" type="text" id="id" readonly="" value="<?php echo $line->transactionid; ?>" style="width:50px;"></td>
739                       <td><div align=
"left"><strong>Date</strong></div></td>
740                       <td><input type=
"text" id="datefield" name="date" class="date_input" value="<?php
741                       
742                       
743         $phpdate = strtotime( $line->date );
744
745         $phpdate = date("
d-m-Y",$phpdate);
746         echo $phpdate;
747 ?>"
style="width:70px;"></td>
748                       <td>&nbsp;</td>
749                       <td>&nbsp;</td>
750                     </tr>
751                     <tr>
752                       <td width=
"61">&nbsp;</td>
753                       <td width=
"110">&nbsp;</td>
754                       <td width=
"15"><div align="left"></div></td>
755                       <td width=
"76">&nbsp;</td>
756                       <td width=
"171"><div align="left"></div></td>
757                       <td width=
"74">&nbsp;</td>
758                       <td width=
"111"><div align="left"></div></td>
759                       <td width=
"77">&nbsp;</td>
760                       <td width=
"105">&nbsp;</td>
761                     </tr>
762                     <tr>
763                       <td><div align=
"center"><strong>Bill No</strong></div></td>
764                       <td><input type=
"text" name="billnumber" style="width:100px;" id="billnumber" class="validate[required,length[0,100]] text-input" value="<?php echo $line->billnumber; ?>"></td>
765                       <td>&nbsp;</td>
766                       <td><div align=
"left"><strong>Customer</strong></div></td>
767                       <td><input name=
"customer1" type="text" id="customer" value="<?php echo $line->customer_id; ?>" style="width:100px;" autocomplete="off" ></td>
768                       <td><div align=
"left">Address</div></td>
769                       <td><textarea name=
"address1" id="address" style="width:100px;"><?php echo $db->queryUniqueValue("SELECT customer_address FROM customer_details WHERE customer_name='$line->customer_id'"); ?></textarea></td>
770                       <td><div align=
"left">Contact1<br>
771                               <br>
772                         Contact2</div></td>
773                       <td><input name=
"contact1" type="text" id="contact1" value="<?php echo $db->queryUniqueValue("SELECT customer_contact1 FROM customer_details WHERE customer_name='$line->customer_id'"); ?>" style="width:80px;">
774                           <br>
775                           <br>
776                           <input name=
"contact2" type="text" id="contact2" value="<?php echo $db->queryUniqueValue("SELECT customer_contact2 FROM customer_details WHERE customer_name='$line->customer_id'"); ?>" style="width:80px;" ></td>
777                     </tr>
778                     <tr>
779                       <td>&nbsp;</td>
780                       <td>&nbsp;</td>
781                       <td><div align=
"left"></div></td>
782                       <td>&nbsp;</td>
783                       <td><div align=
"left"></div></td>
784                       <td>&nbsp;</td>
785                       <td><div align=
"left"></div></td>
786                       <td>&nbsp;</td>
787                       <td>&nbsp;</td>
788                     </tr>
789                    </table>
790                   <br>
791
792                     <table width=
"800" border="0" cellspacing="0" cellpadding="0" id="duplicate" style="margin-left:20px;">
793                         
794                         <?php
795                     $max = $db->maxOf(
"count1", "stock_sales", "transactionid='$id'");
796                     $j=
0;
797                     
for($i=1; $i<=$max; $i++)
798                     {
799                     
800                     ?>
801                         
802                         <tr>
803                       <td ><div align=
"center"><strong>Name</strong></div></td>
804                       <td ><input name=
"name[]" type="text" class="validate[required,length[0,100]] text-input" id="0<?php echo 0+$j;?>" style="width:100px;" onFocus="callAutoComplete(this.id)" onBlur="callAutoAsignValue(this.id)" autocomplete="off" value="<?php
805                     echo $db->queryUniqueValue("
SELECT stock_name FROM stock_sales WHERE transactionid='$id' and count1=$i");
806                       ?>"
></td>
807                       <td><div align=
"left"><strong>Quantity</strong></div></td>
808                       <td><input name=
"quantity[]" type="text" id="00<?php echo 1+$j;?>" class="validate[required,custom[onlyFloat],lengthCheck[6]] text-input" style="width:50px;" onKeyUp="callQKeyUp(this.id)" value="<?php
809                     echo $db->queryUniqueValue("
SELECT quantity FROM stock_sales WHERE transactionid='$id' and count1=$i");
810                       ?>"
></td>
811                       <td><div align=
"left"><strong>Rate:</strong></div></td>
812                       <td><input name=
"rate[]" type="text" id="000<?php echo 2+$j;?>" class="validate[required,custom[onlyFloat],lengthCheck[6]] text-input" style="width:50px;" onKeyUp="callRKeyUp(this.id)" value="<?php
813                     echo $db->queryUniqueValue("
SELECT selling_price FROM stock_sales WHERE transactionid='$id' and count1=$i");
814                       ?>"
></td>
815                       <td>Avail Qty</td>
816                         <td><input name=
"avail[]" type="text" id="0000<?php echo 3+$j;?>" readonly="" value="" style="width:50px;" ></td>
817                       <td><div align=
"left"><strong>Total:</strong></div></td>
818                       <td><input name=
"total[]" type="text" id="00000<?php echo 4+$j;?>" readonly="" value="<?php
819                     echo $db->queryUniqueValue("
SELECT selling_price FROM stock_sales WHERE transactionid='$id' and count1=$i");
820                       ?>"
style="width:100px;text-align:right;" > </td>
821                       <td width=
"50"><p><span><a id="minus" href="" >[-]</a> <a id="plus" href="">[+]</a></span></p></td>
822                     </tr>
823                     <?php
824                       $j=$j+
5;
825                       }
826                       ?>
827                     
828                     
829                       <tr>
830                         <td>&nbsp;</td>
831                         <td>&nbsp;</td>
832                         <td>&nbsp;</td>
833                         <td>&nbsp;</td>
834                         <td>&nbsp;</td>
835                         <td>&nbsp;</td>
836                         <td>&nbsp;</td>
837                         <td>&nbsp;</td>
838                         <td>&nbsp;</td>
839                         <td>&nbsp;</td>
840                         <td>&nbsp;</td>
841                       </tr>
842                       </table>
843                       <table width=
"800" border="0" align="center" cellpadding="0" cellspacing="0" id="duplicate" style="margin-left:20px;">
844                       <tr>
845                         <td>&nbsp;</td>
846                         <td>&nbsp;</td>
847                         <td>&nbsp;</td>
848                         <td>&nbsp;</td>
849                         <td>&nbsp;</td>
850                         <td width=
"103">&nbsp;</td>
851                         <td width=
"140">&nbsp;</td>
852                         <td width=
"5">&nbsp;</td>
853                         <td width=
"5">&nbsp;</td>
854                         <td width=
"5">&nbsp;</td>
855                         <td width=
"13">&nbsp;</td>
856                       </tr>
857                       <tr>
858                         <td>Payment:</td>
859                         <td><input type=
"text" name="payment" style="width:100px; " id="payment" class="validate[required,custom[onlyFloat],lengthCheck[6]] text-input" onKeyUp="balanceCalc()" value="<?php
860                     echo $db->queryUniqueValue("
SELECT payment FROM stock_sales WHERE transactionid='$id'");
861                       ?>"
></td>
862                         <td><div align=
"left">Description</div></td>
863                         <td rowspan=
"2"><textarea name="description" style="width:150px; height:40px; "><?php
864                     echo $db->queryUniqueValue(
"SELECT description FROM stock_sales WHERE transactionid='$id'");
865                       ?></textarea></td>
866                         <td>&nbsp;</td>
867                         <td><div align=
"center"><strong>Sub Total </strong></div></td>
868                         <td><input name=
"subtotal" id="subtotal" type="text" value="<?php
869                     echo $db->queryUniqueValue("
SELECT subtotal FROM stock_sales WHERE transactionid='$id'");
870                       ?>"
readonly="" style="width:100px; text-align:right; color:#333333; font-weight:bold; font-size:16px;"><img src="images/refresh.png" alt="Refresh" align="absmiddle" onClick="updateSubtotal()"></td>
871                         <td>&nbsp;</td>
872                         <td>&nbsp;</td>
873                         <td>&nbsp;</td>
874                         <td>&nbsp;</td>
875                       </tr>
876                       <tr>
877                         <td>Balance:</td>
878                         <td><input name=
"balance" type="text" id="balance" style="width:100px; " value="<?php
879                     echo $db->queryUniqueValue("
SELECT balance FROM stock_sales WHERE transactionid='$id'");
880                       ?>"
readonly=""></td>
881                         <td>&nbsp;</td>
882                         <td>&nbsp;</td>
883                         <td><div align=
"center"></div></td>
884                         <td>&nbsp;</td>
885                         <td>&nbsp;</td>
886                         <td>&nbsp;</td>
887                         <td>&nbsp;</td>
888                         <td>&nbsp;</td>
889                       </tr>
890                       <tr>
891                         <td>&nbsp;</td>
892                         <td>&nbsp;</td>
893                         <td>&nbsp;</td>
894                         <td>&nbsp;</td>
895                         <td>&nbsp;</td>
896                         <td>&nbsp;</td>
897                         <td>&nbsp;</td>
898                         <td>&nbsp;</td>
899                         <td>&nbsp;</td>
900                         <td>&nbsp;</td>
901                         <td>&nbsp;</td>
902                         </tr>
903                       <tr>
904                         <td width=
"55">Mode:</td>
905                         <td width=
"125"><select name="mode">
906                         <option
value="cheque">Cheque</option>
907                         <option
value="cash" selected>Cash</option>
908                         <option
value="others">others</option>
909                         
910                           </
select></td>
911                         <td width=
"77">Due Date </td>
912                         <td width=
"195"><input type="text" id="due" name="due" class="date_input" value="<?php echo date('d-m-Y');?>" style="width:70px;"></td>
913                         <td width=
"77">&nbsp;</td>
914                         <td>&nbsp;</td>
915                         <td>&nbsp;</td>
916                         <td>&nbsp;</td>
917                         <td>&nbsp;</td>
918                         <td>&nbsp;</td>
919                         <td>&nbsp;</td>
920                       </tr>
921                       <tr>
922                         <td>&nbsp;</td>
923                         <td>&nbsp;</td>
924                         <td>&nbsp;</td>
925                         <td>&nbsp;</td>
926                         <td>&nbsp;</td>
927                         <td><div align=
"center">
928                             <input type=
"button" name="Reset" value="Reset" >
929                         </div></td>
930                         <td><input type=
"submit" name="Submit" value="Save" onClick="updateSubtotal()" ></td>
931                         <td>&nbsp;</td>
932                         <td>&nbsp;</td>
933                         <td>&nbsp;</td>
934                         <td>&nbsp;</td>
935                         </tr>
936                     </table>
937                 
938                 </form></td>
939               </tr>
940             </table>
941             
942         </td>
943           </tr>
944           <tr>
945             <td height=
"30" align="center" bgcolor="#72C9F4"><span class="style1"><a href="http://www.pluskb.com">Developed by PlusKB Innovations</a></span></td>
946           </tr>
947         </table></td>
948       </tr>
949     </table></td>
950   </tr>
951 </table>
952
953 </body>
954 </html>
955 <?php
956 }

957 else

958  echo
"Applicatio can not process without id parameter";
959 }
960 ?>


Gõ tìm kiếm nhanh...